<?php

namespace app\admin\model;

use think\Db;
use think\Model;

class NticeqkModel extends Model
{

    // 设置数据表（不含前缀）
    protected $name = 'ntice_qk';
    // 设置当前模型对应的完整数据表名称
    protected $table = 'ld_ntice_qk';

    public function __construct($data = [])
    {
        parent::__construct($data);
    }


    /**
     * @param $data
     * @param 添加公告
     */
    public function polist($data){
        $query = Db::name($this->name)->insert($data);
        return $query;
    }


    /**
     * @param 获取公告列表
     */
    public function problist($where,$pust,$page,$limit){
        $query = Db::name($this->name)->where($where)->where($pust)->page($page)->limit($limit)->order('id desc')->field('id,title,Bulletin,enable,tlaisrol,types,addTime,updateTime')->select();
        return $query;
    }


    /**
     * @param $id
     * @param 获取当前公告
     */
    public function datalist($id){
        $query = Db::name($this->name)->where('id',$id)->find();
        return $query;
    }


    /**
     * @param $where
     * @param $data
     * @param 修改公告
     */
    public function edisont($where,$data){
        $query = Db::name($this->name)->where($where)->update($data);
        return $query;
    }


    /**
     * @param $where
     * @param 获取当前公告状态
     */
    public function exbut($where){
        $query = Db::name($this->name)->where($where)->find();
        return $query;
    }


    /**
     * @param $where
     * @param $data
     * @param 告禁用、启用
     */
    public function eidtion($where,$data){
        $query = Db::name($this->name)->where($where)->update($data);
        return $query;
    }


    /**
     * @param $id
     * @param 删除公告
     */
    public function del($id){
        $query = Db::name($this->name)->where('id',$id)->delete();
        return $query;
    }

    /**
     * @param $where
     * @param $pust
     * @return mixed
     * @param 总条数
     */
    public function county($where,$pust){
        $query = Db::name($this->name)->where($where)->where($pust)->count();
        return $query;
    }


    /**
     * @param $where
     * @param 获取推送用户
     */
    public function wailist($where){
        $query = Db::name($this->name)->where($where)->field('id,title,Bulletin,userid')->order("addTime desc")->select();
        return $query;
    }


    /**
     * @param $where
     * @param $data
     * @param 写入推送用户ID
     */
    public function lisrent($where,$data){
        $query = Db::name($this->name)->where($where)->update($data);
        return $query;
    }
    
}